import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("user", { schema: "predict" })
export class User {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", { name: "account", length: 15, default: () => "'账号'" })
  account: string;

  @Column("varchar", { name: "address", length: 64, default: () => "'地址'" })
  address: string;

  @Column("int", {
    name: "group_id",
    comment: "用户类型",
    unsigned: true,
    default: () => "'0'",
  })
  groupId: number;

  @Column("int", {
    name: "expire_at",
    comment: "有效期",
    unsigned: true,
    default: () => "'0'",
  })
  expireAt: number;

  @Column("json", { name: "parents", nullable: true, comment: "上级" })
  parents: object | null;

  @Column("int", {
    name: "direct_parent",
    comment: "直接上级",
    unsigned: true,
    default: () => "'0'",
  })
  directParent: number;

  @Column("decimal", {
    name: "balance",
    comment: "余额",
    precision: 8,
    scale: 2,
    default: () => "'0.00'",
  })
  balance: string;

  @Column("decimal", {
    name: "commission_amount",
    comment: "佣金",
    precision: 8,
    scale: 2,
    default: () => "'0.00'",
  })
  commissionAmount: string;

  @Column("char", { name: "password", length: 64 })
  password: string;

  @Column("char", { name: "salt", length: 12 })
  salt: string;

  @Column("tinyint", { name: "enable", width: 1, default: () => "'1'" })
  enable: boolean;

  @Column("int", {
    name: "register_time",
    unsigned: true,
    default: () => "'0'",
  })
  registerTime: number;

  @Column("int", {
    name: "last_login_time",
    unsigned: true,
    default: () => "'0'",
  })
  lastLoginTime: number;
}
